<template>
	<view class="">
		<view class="flex-1 mt-5 row font-s-4 text-light-muted" v-if="examineList.length == 0">无审核用户</view>
		<view class="flex-1 mt-3 mx-3 row-ac-sb py-3 border-bottom" v-for="(item,index) in examineList" :key="index"
			v-if="examineList.length > 0">
			<view class="flex-1">
				<view class="row-ac">
					<view class="head-image ml-4">
						<image :src="item.head_image" mode=""></image>
					</view>
					<view class="ml-2">
						<view class="font-s-5">用户:{{ item.nick_name || item.user_name }}</view>
						<view class="font-s-2 text-muted mt">身份: {{ item.identity_name }}</view>
					</view>
				</view>
				<view class="mt-2 ml-5">
					<view class="font-s-2 text-muted">电话: {{ item.user_phone }}</view>
					<view class="font-s-2 text-muted">申请时间: {{ item.addly_time }}</view>
				</view>
			</view>
			<view class="mr-2" v-if="item.addly_status == 1">
				<view class="font-s-4">审核通过..</view>
			</view>
			<view class="mr-2" v-if="item.addly_status == 2" @click="examineAddly(item.id)">
				<view class="font-s-3 row examine-box">审核</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		useridentityexamineListUrl,
		useridentityexaminePatchUrl
	} from "@/api/index.js"
	export default {
		data() {
			return {
				examineueryInfo: {
					addly_status: ''
				},
				examineList: [],
				formData: {
					addly_status: 1,
					identity: 2
				}
			}
		},
		onLoad() {
			this.getUseridentityexamineList()
		},
		methods: {
			getUseridentityexamineList() {
				this.$R.get(useridentityexamineListUrl, this.examineueryInfo).then(res => {
					this.examineList = res.data.list
					this.examineTotal = res.data.total
					console.log(this.examineTotal);
				})
			},
			examineAddly(examineId) {
				uni.showModal({
					title: '审核代理',
					content: '是否通过该会员成为代理？',
					cancelText: '不通过',
					confirmText: '确认通过',
					success: (res) => { // 使用箭头函数
						if (res.confirm) {
							this.$R.patch(useridentityexaminePatchUrl + examineId + '/', this.formData).then(
								res => {
									if (res.code == 200) {
										uni.showToast({
											title: '通过审核',
											icon: 'none'
										});
										this.getUseridentityexamineList()
									}
								})
						} else if (res.cancel) {
							uni.showToast({
								title: '不通过',
								icon: 'none'
							});
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff !important;
	}

	.promotion-head {
		position: relative;

		.to-back {
			position: absolute;
			top: 90rpx;
			left: 30rpx;
		}

		.promotion-title {
			top: 150rpx;
			right: 90rpx;
			position: absolute;
		}
	}

	.user-img {
		width: 238rpx;
		height: 238rpx;
		border-radius: 50%;
		border: 20rpx solid #D2D2D2;

		image {
			width: 238rpx;
			height: 238rpx;
			border-radius: 50%;
		}
	}

	.head-image {
		width: 72rpx;
		height: 72rpx;
		border-radius: 50%;

		image {
			width: 72rpx;
			height: 72rpx;
			border-radius: 50%;
		}
	}

	.examine-box {
		width: 160rpx;
		height: 72rpx;
		background-color: #000;
		color: #fff;
	}
</style>